# Block quotes

block quote marker (opens new window) consists of 0-3 spaces of initial indent, plus (a) the character > together with a following space, or (b) a single character > not followed by a space.

The following rules define block quotes (opens new window):

  1. Basic case. If a string of lines Ls constitute a sequence of blocks Bs, then the result of prepending a block quote marker (opens new window) to the beginning of each line in Ls is a block quote (opens new window) containing Bs.
  2. Laziness. If a string of lines Ls constitute a block quote (opens new window) with contents Bs, then the result of deleting the initial block quote marker (opens new window) from one or more lines in which the next non-whitespace character (opens new window) after the block quote marker (opens new window) is paragraph continuation text (opens new window) is a block quote with Bs as its content. Paragraph continuation text (opens new window) is text that will be parsed as part of the content of a paragraph, but does not occur at the beginning of the paragraph.
  3. Consecutiveness. A document cannot contain two block quotes (opens new window) in a row unless there is a blank line (opens new window)between them.

Nothing else counts as a block quote (opens new window).
Here is a simple example:

Example 206

Markdown HTML Demo
> # Foo
> bar
> baz

<blockquote>
<h1>Foo</h1>
<p>bar
baz</p>
</blockquote>

The spaces after the > characters can be omitted:

Example 207

Markdown HTML Demo
># Foo
>bar
> baz

<blockquote>
<h1>Foo</h1>
<p>bar
baz</p>
</blockquote>

The > characters can be indented 1-3 spaces:

Example 208

Markdown HTML Demo
   > # Foo
   > bar
 > baz

<blockquote>
<h1>Foo</h1>
<p>bar
baz</p>
</blockquote>

Four spaces gives us a code block:

Example 209

Markdown HTML Demo
    > # Foo
    > bar
    > baz

<pre><code>&gt; # Foo
&gt; bar
&gt; baz
</code></pre>

The Laziness clause allows us to omit the > before paragraph continuation text (opens new window):

Example 210

Markdown HTML Demo
> # Foo
> bar
baz

<blockquote>
<h1>Foo</h1>
<p>bar
baz</p>
</blockquote>

A block quote can contain some lazy and some non-lazy continuation lines:

Example 211

Markdown HTML Demo
> bar
baz
> foo

<blockquote>
<p>bar
baz
foo</p>
</blockquote>

Laziness only applies to lines that would have been continuations of paragraphs had they been prepended with block quote markers (opens new window). For example, the > cannot be omitted in the second line of

> foo
> ---

without changing the meaning:

Example 212

Markdown HTML Demo
> foo
---

<blockquote>
<p>foo</p>
</blockquote>
<hr />

Similarly, if we omit the > in the second line of

> - foo
> - bar

then the block quote ends after the first line:

Example 213

Markdown HTML Demo
> - foo
- bar

<blockquote>
<ul>
<li>foo</li>
</ul>
</blockquote>
<ul>
<li>bar</li>
</ul>

For the same reason, we can’t omit the > in front of subsequent lines of an indented or fenced code block:

Example 214

Markdown HTML Demo
>     foo
    bar

<blockquote>
<pre><code>foo
</code></pre>
</blockquote>
<pre><code>bar
</code></pre>

Example 215

Markdown HTML Demo
> ```
foo
```

<blockquote>
<pre><code></code></pre>
</blockquote>
<p>foo</p>
<pre><code></code></pre>

Note that in the following case, we have a lazy continuation line (opens new window):

Example 216

Markdown HTML Demo
> foo
    - bar

<blockquote>
<p>foo
- bar</p>
</blockquote>

To see why, note that in

> foo
>     - bar

the - bar is indented too far to start a list, and can’t be an indented code block because indented code blocks cannot interrupt paragraphs, so it is paragraph continuation text (opens new window).
A block quote can be empty:

Example 217

Markdown HTML Demo
>

<blockquote>
</blockquote>

Example 218

Markdown HTML Demo
>
>  
> 

<blockquote>
</blockquote>

A block quote can have initial or final blank lines:

Example 219

Markdown HTML Demo
>
> foo
>  

<blockquote>
<p>foo</p>
</blockquote>

A blank line always separates block quotes:

Example 220

Markdown HTML Demo
> foo

> bar

<blockquote>
<p>foo</p>
</blockquote>
<blockquote>
<p>bar</p>
</blockquote>

(Most current Markdown implementations, including John Gruber’s original Markdown.pl, will parse this example as a single block quote with two paragraphs. But it seems better to allow the author to decide whether two block quotes or one are wanted.)
Consecutiveness means that if we put these block quotes together, we get a single block quote:

Example 221

Markdown HTML Demo
> foo
> bar

<blockquote>
<p>foo
bar</p>
</blockquote>

To get a block quote with two paragraphs, use:

Example 222

Markdown HTML Demo
> foo
>
> bar

<blockquote>
<p>foo</p>
<p>bar</p>
</blockquote>

Block quotes can interrupt paragraphs:

Example 223

Markdown HTML Demo
foo
> bar

<p>foo</p>
<blockquote>
<p>bar</p>
</blockquote>

In general, blank lines are not needed before or after block quotes:

Example 224

Markdown HTML Demo
> aaa
***
> bbb

<blockquote>
<p>aaa</p>
</blockquote>
<hr />
<blockquote>
<p>bbb</p>
</blockquote>

However, because of laziness, a blank line is needed between a block quote and a following paragraph:

Example 225

Markdown HTML Demo
> bar
baz

<blockquote>
<p>bar
baz</p>
</blockquote>

Example 226

Markdown HTML Demo
> bar

baz

<blockquote>
<p>bar</p>
</blockquote>
<p>baz</p>

Example 227

Markdown HTML Demo
> bar
>
baz

<blockquote>
<p>bar</p>
</blockquote>
<p>baz</p>

It is a consequence of the Laziness rule that any number of initial >s may be omitted on a continuation line of a nested block quote:

Example 228

Markdown HTML Demo
> > > foo
bar

<blockquote>
<blockquote>
<blockquote>
<p>foo
bar</p>
</blockquote>
</blockquote>
</blockquote>

Example 229

Markdown HTML Demo
>>> foo
> bar
>>baz

<blockquote>
<blockquote>
<blockquote>
<p>foo
bar
baz</p>
</blockquote>
</blockquote>
</blockquote>

When including an indented code block in a block quote, remember that the block quote marker (opens new window) includes both the > and a following space. So five spaces are needed after the >:

Example 230

Markdown HTML Demo
>     code

>    not code

<blockquote>
<pre><code>code
</code></pre>
</blockquote>
<blockquote>
<p>not code</p>
</blockquote>